package com.qk.management.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qk.domain.user.UserDO;
import com.qk.dto.user.UserDTO;
import com.qk.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    List<UserDO> selectByPage(UserDTO userDto);

    int insert(User user);

    void update(User user);

    @Delete("delete from user where id=#{id}")
    void deleteById(Integer id);

    @Select("select * from user where id=#{id}")
    User getById(Integer id);

    @Select("select * from user")
    List<User> getAll();

    @Select("select * from user where dept_id=#{deptId}")
    List<User> getByDeptId(Integer deptId);

    @Select("select u.* from user u where u.role_id = (select r.id from role r where r.label = #{roleLabel})")
    List<User> getByRoleLabel(String roleLabel);

    @Select("select * from user where username = #{username}")
    User getByUsername(String username);
}
